<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '2px' }">
    <el-form label-width="72px" @keyup.enter="search">
      <el-form-item label="所属站点">
        <el-radio-group v-model="form.site_id" @change="search">
          <el-radio-button
            v-for="item in cityList"
            :key="item.site_id"
            :label="item.site_id"
            :value="item.site_id"
          >
            {{ item.region_name }}
          </el-radio-button>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="回访类型">
        <el-radio-group
          v-model="form.cate"
          class="filter-item"
          @change="search"
        >
          <el-radio-button label="">全部</el-radio-button>
          <el-radio-button label="全职实习意向">全职实习意向</el-radio-button>
          <el-radio-button label="直接联系">直接联系</el-radio-button>
        </el-radio-group>
      </el-form-item>
    </el-form>
  </ele-card>
</template>

<script setup>
  import { ref } from 'vue';
  import { EleMessage } from 'ele-admin-plus/es';
  import { useFormData } from '@/utils/use-form-data';
  import { getMyCityList } from '@/api/system/region';
  const emit = defineEmits(['search']);

  /** 表单数据 */
  const [form] = useFormData({
    site_id: '',
    cate: ''
  });

  /** 站点数据 */
  const cityList = ref([]);

  /** 搜索 */
  const search = () => {
    console.log(form);
    emit('search', { ...form });
  };

  /** 获取站点数据 */
  getMyCityList({})
    .then((res) => {
      cityList.value = res;
      // console.log(res[0].site_id);
      // console.log(form.site_id);
      form.site_id = res[0].site_id;
      // assignFields({
      //   site_id: res[0].site_id
      // });
      console.log(form);
    })
    .catch((e) => {
      EleMessage.error(e.message);
    });
</script>
